<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.model.*"%>
<%@ page import="com.control.*"%>
<%@ page import="com.util.PageResultSet"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>查询信息</title>
	</head>
	<body>
		<%
	    request.setCharacterEncoding("UTF-8");
	    int curPage = 1;
	    String ToolBar = "";
		
	    int teacher_id=(Integer)session.getAttribute("id");
	    CourseControl cc = new CourseControl();
	    int course_id = cc.getCourseId(teacher_id);
	    
		%>
		<table width="98%" border="0" align="center">
			<tr>
				<td></td>
			</tr>
			<tr>
				<td></td>
			</tr>
			<tr>
				<td>
					<fieldset>
						<legend>  
							学生成绩列表  
						</legend>
						<form action="Score_Info_show.jsp" name="form1" method="post"><br><table width="90%" border="0" align="center" cellspacing="0"
								cellpadding="0">
								<tr align="center">
									<td align="right">
										<span style="color: rgb(55, 107, 165); margin-top: 10px;"></span>
										<input type="button" value="提交教务处"
											onclick="window.location.href='tijiao_chuli.jsp?course_id=<%=course_id %>'" />
									</td>
								</tr>
								<tr>
									<td>
										<table border="1" width="99%" align="center" cellpadding="0"
											cellspacing="1" class="resultTable">
											<tr>
												<td width="4%" height="25" align="center" bgcolor="#D9F0FF">
													学号
												</td>
												<td width="4%" height="25" align="center" bgcolor="#D9F0FF"> 
													姓名 
												</td>
												<td width="2%" height="25" align="center" bgcolor="#D9F0FF"> 
													分数<br></td>
												<td width="5%" height="25" align="center" bgcolor="#D9F0FF">
													操作
												</td>
								</tr>
								<%
									
									ScoreControl sc = new ScoreControl();
									ArrayList<Score> list = new ArrayList<Score>();
									list =sc.getAllStudentScore(course_id);
									if(request.getParameter("cur_page")!= null) {
										curPage = Integer.parseInt(request.getParameter("cur_page")); 
									}
									PageResultSet p = new PageResultSet(list,curPage);
									ArrayList<Score> nowlist = new ArrayList<Score>();
									nowlist = (ArrayList<Score>)p.getData();
										
									for(int i=0; i<nowlist.size(); i++) {
										Score score = nowlist.get(i);
										int student_id = score.getStudent_id();
										UserControl uc = new UserControl();
										User user = uc.getUser(student_id);
							 	%>
								 	<tr>
        								<td height="25" align="center"><%=user.getUsername()%></td>
 										<td height="25" align="center"><%=user.getName()%></td>
 										<%
 											float point = score.getPoint();
 											String url = "update_score.jsp?score_id=" + score.getId() + "&username=" + user.getUsername() + 
 											"&name=" + user.getName() ;
 											int course = score.getCourse_id();
 											if(cc.Lock(course_id)){
 										%>
 										<td height="25" align="center"><%=score.getPoint()%></td>
 										<td height="25" align="center">锁定</a>
 										<%
 											}else{
 											if(point>=0){
 										 %>
 										<td height="25" align="center"><%=score.getPoint()%></td>
 										<td height="25" align="center"><a href=<%=url %>>修改</a>
 										<%}else{
 										 %>
 										 <td height="25" align="center">未录入</td>
 										<td height="25" align="center"><a href=<%=url %>>添加</a>
 										 <%} %>
 		 							</tr>
   									<%}}
   										
										String fileName = "Score_Info_show.jsp";
										ToolBar = p.getToolBar(fileName);
									%>
							</table>
							<%=ToolBar %>
							</td>
							</tr>
							</table>
						</form>
					</fieldset>
				</td>
			</tr>
		</table>
	</body>
</html>
